#include "md2\md2Player.h"
#include "hero.h"
#include "draw.h"
#include "terrain.h" // para calcular a altura
#include "definitions.h"
#include "toolkits/includes/glut.h"
#include "toolkits/includes/glm.h"
#include <stdio.h>
#include "toolkits/includes/il.h"

extern GLfloat currentColor[3];
//extern float HEROSCALEFACTOR;
extern GLMmodel *hero;
extern float xpos, zpos, ypos;
extern Terrain *terrainClass;
extern ILint heightW, heightH;
extern float heightMap[TERRAINLENGTH*2][TERRAINLENGTH*2];
extern float heroPosition[3];
extern float altura;
extern Md2Player *jogador;

Hero::Hero() {
	moving = false;
	life = 3;
}

void Hero::setLife(int life){
	this->life = life;
}

int Hero::getLife(){
	return this->life;
}

void Hero::drawHero() {
	glPushMatrix();
  glTranslatef(0.0f, altura-HEROSCALEFACTOR, 0.0f);
		Draw::setColor(0.0f, 1.0f, 0.0f);
		glScalef(HEROSCALEFACTOR, HEROSCALEFACTOR, HEROSCALEFACTOR);
		glmDraw(hero, GLM_MATERIAL | GLM_SMOOTH);  
		glColor3fv(currentColor);
	glPopMatrix();
}

void Hero::drawHeroMD2() {
	glPushMatrix();
		glRotatef(180,0.0,1.0,0.0); // hero facing forward
		glTranslatef(0.0f, altura-1.6f, 0.0f);
		if(moving>0) {
            jogador->drawPlayerItp (true,static_cast<Md2Object::Md2RenderMode>(0));
			jogador->animate(0.4);
        }
        else {
			jogador->animate(0.0);
            jogador->drawPlayerFrame (0,static_cast<Md2Object::Md2RenderMode>(0));
        }
	glPopMatrix();
}